<!--
 * @Author: LHL
 * @Date: 2022-10-12 11:20:51
 * @LastEditTime: 2022-10-16 17:55:58
 * @LastEditors: lhl
 * @Description: 
 * @FilePath: \新建文件夹 (2)\jep-training-trinity-group\briup-ui\src\pages\admin\log\List.vue
 * 别乱动！
-->
<template>
  <div>
    <!-- 表单数据开始 -->
    <el-table :data="tableData" style="width: 100%" v-loading='loading'>
      <el-table-column type="index" :index="1" label="序号" width="180">
      </el-table-column>
      <el-table-column prop="realname" label="真实姓名">
      </el-table-column>
      <el-table-column prop="method" label="访问方式">
      </el-table-column>
      <el-table-column prop="content" label="访问路径">
      </el-table-column>
      <el-table-column prop="logTime" label="访问时间">
        <template slot-scope="scope">
          {{scope.row.logTime | fmtDate}}
        </template>
      </el-table-column>
    </el-table>
    <!-- 表单数据结束 -->
    <!-- 分页开始 -->
    <div class="block">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="params.page" :page-sizes="[10, 20, 50, 100]" :page-size="params.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>
    <!-- 分页结束 -->
  </div>
</template>

<script>
import { toLog } from '@/api/log'
import { fmtDate } from '@/filters/index'
export default {
  data() {
    return {
      tableData: [],
      params: {
        page: 1,
        pageSize: 15
      },
      total: 0
    }
  },
  computed: {},
  methods: {
    // 查询所有日志
    async getLogs() {
      this.loading = true
      let res = await toLog(this.params)
      // console.log(res)
      this.tableData = res.data.list
      this.total = res.data.total
      this.loading = false
    },
    // 分页功能
    // 每页多少条
    handleSizeChange(pageSize) {
      this.params.pageSize = pageSize
      this.params.page = 1
      this.getLogs()
    },
    // 当前多少页
    handleCurrentChange(page) {
      this.params.page = page
      this.getLogs()
    }
  },
  created() {
    this.getLogs()
  },
  mounted() {}
}
</script>
<style lang="scss">
.block {
  padding: 20px;
  margin: 10px;
  text-align: center;
}
</style>